﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eProject_SEM3_SecurityServices.ObjectClass;
using eProject_SEM3_SecurityServices.Bussiness;

namespace eProject_SEM3_SecurityServices
{
    public partial class frmAddEmployee : System.Web.UI.Page
    {
        BDepartment depart;
        BEmployee employee;
        protected void Page_Load(object sender, EventArgs e)
        {
            depart = new BDepartment();
            employee = new BEmployee();
            bindData();
        }

        public void bindData()
        {
            List<ODepartment> departList = new List<ODepartment>();
            departList = depart.getDepartmentList();
            ddDepartment.DataSource = departList;
            ddDepartment.DataTextField = "DepartmentName";
            ddDepartment.DataValueField = "DepartmentID";
            ddDepartment.DataBind();
        }

        protected void Button2_Click1(object sender, EventArgs e)
        {
            tbAddress.Text = "";
            tbBirthDay.Text = "";
            tbFullName.Text = "";
            tbPass.Text = "";
            tbPhone.Text = "";
            tbRegion.Text = "";
            tbRole.Text = "";
            tbSalary.Text = "";
            tbUserName.Text = "";
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            OEmployee employ = new OEmployee();
            employ.DepartmentId = Int32.Parse(ddDepartment.SelectedValue);
            employ.EmployeeAddress = tbAddress.Text;
            employ.EmployeeBirthday = tbBirthDay.Text;
            employ.EmployeeFullName = tbFullName.Text;
            employ.EmployeeGender = bool.Parse(ddGender.SelectedValue.ToString());
            employ.EmployeePhone = Int32.Parse(tbPhone.Text);
            employ.EmployeeSalary = tbSalary.Text;
            employ.Password = tbPass.Text;
            employ.Region = tbRegion.Text;
            employ.Role = Int32.Parse(tbRole.Text);
            employ.UserName = tbUserName.Text;
            employee.AddNewEmployee(employ);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("EmployeeManager.aspx");
        }
    }
}